angular
  .module('fs.waf')
  .controller('componentsPageCtrl', [
    '$scope',
    '$translate',
    '$templateCache',
    '$locale',
    'storageService',
    '$uibModal',
    function($scope, $translate, $templateCache, $locale, storageService, $uibModal) {
      // 配置 sessionStorage , angular-local-storage 可以获取 format 格式化的配置参数
      sessionStorage.setItem(
        'FS_APP.FS_BACKHIS_INFO',
        '[{"pageId":"cda.spa.spaView","fromUrl":"signon","fromParams":{"__originalState":"","__state":"signon"},"toUrl":"cda_spa_spaView","toParams":{"__originalState":"signon","__state":"cda_spa_spaView"}},{"pageId":"waf.home","fromUrl":"cda_spa_spaView","fromParams":{"__originalState":"signon","__state":"cda_spa_spaView"},"toUrl":"waf_home","toParams":{"__originalState":"cda_spa_spaView","__state":"waf_home"}}]'
      );

      // "."和","互换模式
      sessionStorage.setItem(
        'FS_APP.FS_FORMAT_INFO',
        '{"decimalSeparator":",","groupSeparator":".","date":"yyyy-MM-dd","defaultFloat":"#0.0##############","defaultMoney":"#,##0.00#","fxRate":"#0.0########","year":"yyyy","longTimestampZ":"yyyy-MM-dd HH:mm:ss.sss Z","defaultPercentage":"#0.0###","integer":"#0","float":"#0.0##############","purchasePercentage":"#0.0###","defaultInteger":"#0","defaultTime":"HH:mm:ss","timestamp":"yyyy-MM-dd HH:mm:ss","timestampZ":"yyyy-MM-dd HH:mm:ss Z","longTimestamp":"yyyy-MM-dd HH:mm:ss.sss","interestRate":"#0.0######","defaultDate":"yyyy-MM-dd","defaultTimestamp":"yyyy-MM-dd HH:mm:ss","orderedDateFormats":["yyyy-MM-dd HH:mm:ss.SSS Z","yyyy-MM-dd HH:mm:ss Z","yyyy-MM-dd HH:mm:ss.SSS","","yyyy-MM-dd","HH:mm:ss.SSS","HH:mm:ss","HH:mm"],"longTime":"HH:mm:ss.sss","month":"yyyy-MM","money":"#,##0.00#","shortTime":"HH:mm:ss","time":"HH:mm:ss","money3":"#,##0.000","money2":"#,##0.00","money1":"#,##0.0","money0":"#,##0"}'
      );

      // sessionStorage.setItem(
      //   'FS_APP.FS_FORMAT_INFO',
      //   '{"date":"yyyy-MM-dd","defaultFloat":"#0.0##############","defaultMoney":"#,##0.00#","fxRate":"#0.0########","year":"yyyy","longTimestampZ":"yyyy-MM-dd HH:mm:ss.sss Z","defaultPercentage":"#0.0###","integer":"#0","float":"#0.0##############","purchasePercentage":"#0.0###","defaultInteger":"#0","defaultTime":"HH:mm:ss","timestamp":"yyyy-MM-dd HH:mm:ss","timestampZ":"yyyy-MM-dd HH:mm:ss Z","longTimestamp":"yyyy-MM-dd HH:mm:ss.sss","interestRate":"#0.0######","defaultDate":"yyyy-MM-dd","defaultTimestamp":"yyyy-MM-dd HH:mm:ss","orderedDateFormats":["yyyy-MM-dd HH:mm:ss.SSS Z","yyyy-MM-dd HH:mm:ss Z","yyyy-MM-dd HH:mm:ss.SSS","","yyyy-MM-dd","HH:mm:ss.SSS","HH:mm:ss","HH:mm"],"longTime":"HH:mm:ss.sss","month":"yyyy-MM","money":"#,##0.00#","shortTime":"HH:mm:ss","time":"HH:mm:ss","money3":"#,##0.000","money2":"#,##0.00","money1":"#,##0.0","money0":"#,##0"}'
      // );

      sessionStorage.setItem(
        'FS_APP.FS_SITE_INFO',
        '{"siteCode":"FSCSBK","siteName":"FSCSBK","baseCcy":"USD","isFxMultiply":"Y","cutoffTime":"1970-01-01 00:39:00.000","bizDate":"2018-03-28 00:00:00.000","eodDate":"2018-03-28 00:00:00.000","intRateDecimals":3,"fxRateDecimals":3,"glSystem":"GLPT-GLSYSTEM","glpostMgr":"GLPT-MGR"}'
      );

      sessionStorage.setItem(
        'FS_APP.FS_USER_INFO',
        '{"date":"yyyy-MM-dd","defaultFloat":"#0.0##############","defaultMoney":"#,##0.00#","fxRate":"#0.0########","year":"yyyy","longTimestampZ":"yyyy-MM-dd HH:mm:ss.sss Z","defaultPercentage":"#0.0###","integer":"#0","float":"#0.0##############","purchasePercentage":"#0.0###","defaultInteger":"#0","defaultTime":"HH:mm:ss","timestamp":"yyyy-MM-dd HH:mm:ss","timestampZ":"yyyy-MM-dd HH:mm:ss Z","longTimestamp":"yyyy-MM-dd HH:mm:ss.sss","interestRate":"#0.0######","defaultDate":"yyyy-MM-dd","defaultTimestamp":"yyyy-MM-dd HH:mm:ss","orderedDateFormats":["yyyy-MM-dd HH:mm:ss.SSS Z","yyyy-MM-dd HH:mm:ss Z","yyyy-MM-dd HH:mm:ss.SSS","","yyyy-MM-dd","HH:mm:ss.SSS","HH:mm:ss","HH:mm"],"longTime":"HH:mm:ss.sss","month":"yyyy-MM","money":"#,##0.00#","shortTime":"HH:mm:ss","time":"HH:mm:ss","money3":"#,##0.000","money2":"#,##0.00","money1":"#,##0.0","money0":"#,##0"}'
      );

      sessionStorage.setItem('FS_APP._com_pti_waf_PAGE_TOKEN_', 'BB10301262001B3CB42AB0E2F7C1C343');

      var fsCardTemplate = require('../htmlTemplate/fsCardTemplate.html');
      $templateCache.put('fs/layout/template/cardTemplate.html', fsCardTemplate);

      var formatInfo = storageService.getFormatInfo();

      if (formatInfo) {
        angular.forEach(formatInfo, function(value, key) {
          if (angular.isString(value)) {
            formatInfo[key] = value.replace('SSS', 'sss');
          }
        });
        storageService.saveFormatInfo(formatInfo);
        angular.extend($locale.DATETIME_FORMATS, formatInfo);
      }

      this.ngModel = {
        linkValue: 'linkValue',
        // textareaValue: '',
        selectValue: 147,
        numberValue: -0.123,
        numberRangeValue: { from: '1', to: '2' },
        moneyValue: 456,
        moneyRangeValue: { from: '45', to: '67' },
        percentageValue: 123456.123456,
        percentageRangeValue: { from: '23', to: '96' },
        imageValue: 'resources/image/logo.png',
        passwordValue: '123456abc',
        // textValue: '',
        textareaValue: 'abc',
        checkboxValue: [123, 147],
        radioValue: 147,
        // cardValue: '',
        // colorValue: '',
        timeValue: new Date(),
        // radioValue: '',
        // radioCardValue: '',
        // calendarDayValue: '',
        sensitiveValue: 'Jack',
        dateValue: new Date(),
        dateRangeValue: {
          from: new Date(),
          to: new Date()
        },
        customerSelectValue: 123,
        lookupTextValue: 'lookup value',
        multipleSelectValue: [123, 147, 1231, 1471],
        lookupMultipleValue: [123, 147]
      };

      this.buttonGroup = {
        aa: 'aa',
        bb: 'bb'
      };

      this.fsGridConfig = {
        fsColor: {
          name: 'color',
          label: 'color',
          model: 'colorValue',
          type: 'color',
          size: 4,
          rules: '', //验证规则
          filter: '', //过滤器
          prefix: 'C', //输入前缀
          inputClass: 'aaa', //输入框样式
          tooltipTemplateUrl: '', //提示器模板路径
          tooltipClass: 'bbb', //提示器样式
          isRequired: false, //添加红色*的样式
          showLabel: false, //是否显示标题
          placeholder: 'color',
          tooltip: 'color',
          help: 'color',
          uppercase: true
        },
        fsLabel: {
          label: 'fs-lalbel component',
          type: 'label',
          size: 4,
          labelClass: 'aaa' //label组件添加样式
        },
        fsLink: {
          active: true,
          show: true,

          type: 'link', //fs-grid 填充的组件类型名
          model: 'linkValue', //和ngModel关联的字段
          appScope: $scope, //绑定页面的$scope

          name: 'link', //
          label: 'link', //组件标题名
          gridClass: 'aaaaa',

          size: 4, //控制组件在页面中所占单元格的长度
          tooltip: 'textarea tooltip', //tooltip 中的提示内容

          options: {
            callback: {
              click: 'callbackFunc'
            }
          }
        },
        fsImage: {
          name: 'image',
          label: 'image',
          model: 'imageValue',
          type: 'image',
          size: 4,
          imgClass: 'aaa'
        },
        fsText: {
          name: 'text',
          label: 'text',
          size: 4,
          help: 'text',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'text',
          model: 'textValue',
          appScope: $scope,

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'text',
          tooltip: 'text',

          prefix: 'Text',

          uppercase: true,

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          rules: '',
          format: 'interestRate',
          filter: '',

          patternOptions: {
            active: true, //boolen
            data: [
              {
                display: '小明',
                value: 123
              },
              {
                display: '小黑',
                value: 147
              }
            ]
          },

          options: {
            // callback: {
            //   click: 'callbackFunc'
            // }
          }

          // name: 'text',
          // label: 'text',
          // model: 'textValue',
          // type: 'text',
          // size: 4,
          // placeholder: 'text',
          // tooltip: 'text',
          // help: 'text',
          // uppercase: true,
          // showLabel: '',
          // isRequired: '',
          // prefix: '%',
          // isNecessary: '',
          // inputClass: 'aaa',
          // tooltipTemplateUrl: '',
          // tooltipClass: 'bbb',
          // tooltipPlacement: '',
          // rules: '',
          // patternOptions: {
          //   active: '', //boolen
          //   data: ''
          // },
          // options: {
          //   data: ''
          // }
        },
        fsPassword: {
          name: 'password',
          label: 'password',
          size: 4,
          help: 'password',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'password',
          model: 'passwordValue',
          appScope: $scope,

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'password',
          tooltip: 'password',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          rules: '',
          filter: '',

          options: {
            // callback: {
            //   changed: 'changedFunc'
            // },
          }
        },
        fsTime: {
          name: 'time',
          label: 'time',
          size: 4,
          help: 'time',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'time',
          model: 'timeValue',
          appScope: $scope,

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'time',
          tooltip: 'time tooltip',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          options: {
            hourStep: true,
            minuteStep: true,
            showSeconds: true,
            isMeridian: true
          }
        },
        fsCheckbox: {
          name: 'checkbox',
          label: 'checkbox',
          size: 4,

          help: 'checkbox',
          inputClass: '',

          showStyle: 'edit', //'view','readonly','edit' or expression

          type: 'checkbox',
          model: 'checkboxValue',
          appScope: $scope,

          tooltip: 'checkbox tooltip',

          isNecessary: false,
          showLabel: true,
          isRequired: true,

          tooltipClass: '',
          tooltipPlacement: 'top-right',

          options: {
            maxChoiceNum: '',
            callback: {
              clicked: 'callbackFunc',
              changed: 'changedFunc'
            },
            data: [
              {
                disabled: false,
                display: '小明',
                value: 123
              },
              {
                disabled: false,
                display: '小黑',
                value: 147
              }
            ]
          }
        },
        fsCheckboxGroup: {
          name: 'checkbox-group',
          label: 'checkbox-group',
          size: 4,

          help: 'checkbox-group',
          inputClass: '',

          showStyle: 'edit', //'view','readonly','edit' or expression

          type: 'checkbox-group',
          model: 'checkboxGroupValue',
          appScope: $scope,

          tooltip: 'checkbox-group tooltip',

          isNecessary: false,
          showLabel: true,
          isRequired: true,

          tooltipClass: '',
          tooltipPlacement: 'top-right',

          options: {
            callback: {
              changed: 'changedFunc'
            },
            groups: [
              {
                isCollapsed: false,
                showHeadCheckbox: true,
                allChecked: false,
                title: 'fsCheckboxGroup',
                data: [
                  {
                    display: '小明',
                    value: 123,
                    desc: 'asdadada'
                  },
                  {
                    display: '小黑',
                    value: 147,
                    desc: 'asdadada'
                  }
                ]
              }
            ]
          }
        },
        fsRadio: {
          name: 'radio',
          label: 'radio',
          size: 4,

          help: 'radio',
          inputClass: '',

          showStyle: 'edit', //'view','readonly','edit' or expression

          type: 'radio',
          model: 'radioValue',
          appScope: $scope,

          tooltip: 'radio tooltip',

          isNecessary: false,
          showLabel: true,
          isRequired: true,

          tooltipClass: '',
          tooltipPlacement: 'top-right',

          options: {
            callback: {
              // clicked: 'callbackFunc',
              changed: 'changedFunc'
            },
            data: [
              {
                disabled: false,
                display: '小明',
                value: 123
              },
              {
                disabled: false,
                display: '小黑',
                value: 147
              }
            ]
          }
        },
        fsRadioCard: {
          name: 'radio-card',
          label: 'radio-card',
          size: 4,

          help: 'radio-card',
          inputClass: '',

          // showStyle: 'edit', //'view','readonly','edit' or expression

          type: 'radio-card',
          model: 'radioCardValue',
          appScope: $scope,
          template:
            '<div class="jumbotron card-default text-center"><h5><span class="icon {{formComponentCtrl.fsGridConfig.options.data.icon}}"></span>{{formComponentCtrl.fsGridConfig.options.data.size}}</h5><h6>{{formComponentCtrl.fsGridConfig.options.data.description | translate}}</h6></div>',

          tooltip: 'radio-card tooltip',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          options: {
            callback: {
              changed: 'changedFunc'
            },
            data: [
              {
                display: 'ERROR',
                value: 'E',
                extProperty: 123
              }
            ]
          }
        },
        fsCard: {
          name: 'card',
          label: 'card',
          size: 4,

          type: 'card',
          model: 'cardValue',

          // template: '<div><h5>{{formComponentCtrl.fsGridConfig.options.display}}</h5><h6>{{formComponentCtrl.fsGridConfig.options.value }}</h6></div>',
          // templateUrl: 'fs/layout/template/cardTemplate.html',

          options: {
            display: '小黑',
            value: 147
          }
          // name: 'card',
          // label: 'card',
          // model: 'cardValue',
          // type: 'card',
          // size: 4,
          // template: '', //模板
          // templateUrl: '', //模板路径
          // options: {
          //   data: ''
          // }
        },
        fsTextarea: {
          // active: false, //boolen or expression
          // show: false, //boolen or expression
          // readonly: true, //boolen or expression
          showStyle: 'edit', //'view','readonly','edit' or expression
          // help: 'textarea',

          type: 'textarea', //fs-grid 填充的组件类型名
          model: 'textareaValue', //和ngModel关联的字段
          appScope: $scope,

          name: 'textarea', //
          label: 'textarea', //组件标题名

          size: 4, //控制组件在页面中所占单元格的长度
          // showLabel: true, //如果有label属性,则默认为true
          // isRequired: true, //设置必填项,如果 rule.ruleName == 'required',则默认为true
          // isNecessary: true, //为必填项提供样式的标识符
          inputClass: '', //提供inputClass样式,如果没有设置则提供默认的样式'input-sm',但当 type == 'radio'或 type == 'checkbox' 则不提供
          placeholder: 'textarea', //placeholder中的内容

          tooltip: 'textarea tooltip', //tooltip 中的提示内容
          uppercase: false, //Boolean 输入字母为大写,如果不设置的默认为true
          filter: '',

          options: {
            // callback: {
            //   changed: 'changedFunc'
            // },
            rows: '4', //行数
            cols: '2' //列数
          }
        },
        fsSelect: {
          name: 'select',
          label: 'select',
          size: 4,

          help: 'select',
          inputClass: '',

          showStyle: 'edit', //'view','readonly','edit' or expression

          type: 'select',
          model: 'selectValue',
          appScope: $scope,

          tooltip: 'select tooltip',

          isNecessary: false,
          showLabel: true,
          isRequired: true,

          tooltipClass: '',
          tooltipPlacement: 'top-right',

          options: {
            callback: {
              changed: 'changedFunc'
            },
            hasEmptyOption: '',
            data: [
              {
                display: '小明',
                value: 123
              },
              {
                display: '小黑',
                value: 147
              }
            ]
          }
        },
        fsDate: {
          name: 'date',
          label: 'date',
          size: 4,

          help: 'date',
          inputClass: '',

          showStyle: 'edit', //'view','readonly','edit' or expression

          type: 'datetime', //'date','datetime' 可配置的参数
          model: 'dateValue',
          appScope: $scope,

          isNecessary: false,
          showLabel: true,
          isRequired: true,

          tooltip: 'date tooltip',

          format: 'timestamp', //date (显示年月日),timestamp(年月日+时分秒)
          // filter: '',

          // closeOnDateSelection: true, //boolean  默认值为true

          options: {
            callback: {
              changed: 'changedFunc'
            },
            ccy: 'USD',
            countrySelectable: '',
            mode: '',
            maxMode: '',
            minMode: '',
            startingDay: '',
            dateDisabled: '',
            maxDate: '',
            minDate: '',
            initDate: '',
            holidaySelectable: true
          }
        },
        fsDateRange: {
          name: 'dateRange',
          label: 'dateRange',
          size: 4,

          help: 'dateRange',
          inputClass: '',

          showStyle: 'edit', //'view','readonly','edit' or expression

          type: 'datetime-range', //'date-range','datetime-range' 可配置的参数
          model: 'dateRangeValue',
          appScope: $scope,

          isNecessary: false,
          showLabel: true,
          isRequired: true,

          tooltip: 'dateRange tooltip',

          format: 'timestamp', //date (显示年月日),timestamp(年月日+时分秒)
          // filter: '',

          // closeOnDateSelection: true, //boolean  默认值为true

          options: {
            // callback: {
            //   changed: 'changedFunc'
            // },
            ccy: 'USD' //币种(有问题)
            //   countrySelectable: '', //boolean 国家选择
            //   mode: '', //视图
            //   maxMode: '', //年视图
            //   minMode: '', //日视图
            //   startingDay: '',
            //   dateDisabled: '',
            //   maxDate: '',
            //   minDate: '',
            //   initDate: '', //
            //   holidaySelectable: true
          }
        },
        fsCalendarDay: {
          name: 'calendarDays',
          size: 4,

          help: 'calendarDays',
          inputClass: '',

          type: 'calendarDays', //'date-range','datetime-range' 可配置的参数
          model: 'calendarDaysValue',
          appScope: $scope,

          options: {
            calendarYear: 2018
          }
        },
        fsNumber: {
          name: 'number',
          label: 'number',
          size: 4,
          help: 'number',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'number',
          model: 'numberValue',
          appScope: $scope,

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'number',
          tooltip: 'number',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          rules: '',
          format: '#,##0.00#',
          filter: '',

          options: {
            callback: {
              changed: 'changedFunc'
            },
            allowNegative: true //允许输入负号
          }
        },
        fsNumberRange: {
          name: 'number-range',
          label: 'number-range',
          size: 4,
          help: 'number-range',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'number-range',
          model: 'numberRangeValue',
          appScope: $scope,

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'number-range',
          tooltip: 'number-range',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          rules: '',
          format: 'interestRate',
          filter: '',

          options: {
            // callback: {
            //   changed: 'changedFunc'
            // },
            allowNegative: '' //允许输入负号
          }
        },
        fsMoney: {
          name: 'money',
          label: 'money',
          size: 4,
          help: 'money',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'money',
          model: 'moneyValue',
          appScope: $scope,

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'money',
          tooltip: 'money',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          rules: '',
          format: 'defaultMoney',
          filter: '',

          options: {
            // callback: {
            //   changed: 'changedFunc'
            // },
            allowNegative: false //允许输入负号
          }
        },
        fsMoneyRange: {
          name: 'money-range',
          label: 'money-range',
          size: 4,
          help: 'money-range',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'money-range',
          model: 'moneyRangeValue',
          appScope: $scope,

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'money-range',
          tooltip: 'money-range',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          rules: '',
          format: 'money3',
          filter: '',

          options: {
            // callback: {
            //   changed: 'changedFunc'
            // },
            allowNegative: true //允许输入负号
          }
        },
        fsPercentage: {
          name: 'percentage',
          label: 'percentage',
          size: 4,
          help: 'percentage',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'percentage',
          model: 'percentageValue',
          appScope: $scope,

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'percentage',
          tooltip: 'percentage',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          rules: '',
          format: 'defaultPercentage',
          filter: '',

          options: {
            // callback: {
            //   changed: 'changedFunc'
            // },
            allowNegative: true //允许输入负号
          }
        },
        fsPercentageRange: {
          name: 'percentage-range',
          label: 'percentage-range',
          size: 4,
          help: 'percentage-range',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'percentage-range',
          model: 'percentageRangeValue',
          appScope: $scope,

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'percentage-range',
          tooltip: 'percentage-range',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          rules: '',
          format: 'defaultPercentage',
          filter: '',

          options: {
            // callback: {
            //   changed: 'changedFunc'
            // },
            allowNegative: true //允许输入负号
          }
        },
        fsTypeahead: {
          name: 'typeahead',
          label: 'typeahead',
          size: 4,
          help: 'typeahead',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'typeahead',
          model: 'typeaheadValue',
          appScope: $scope,

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'typeahead',
          tooltip: 'typeahead tooltip',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          rules: '',
          format: '',
          filter: '',

          options: {
            // callback: {
            //   changed: 'changedFunc'
            // },
            data: [
              {
                display: '小明',
                value: 123
              },
              {
                display: '小黑',
                value: 147
              },
              {
                display: '小明',
                value: 123
              },
              {
                display: '小黑',
                value: 147
              },
              {
                display: '小明',
                value: 123
              },
              {
                display: '小黑',
                value: 147
              },
              {
                display: '小明',
                value: 123
              },
              {
                display: '小黑',
                value: 147
              },
              {
                display: '小明',
                value: 123
              },
              {
                display: '小黑',
                value: 147
              },
              {
                display: '小明',
                value: 123
              },
              {
                display: '小黑',
                value: 147
              },
              {
                display: '小明',
                value: 123
              },
              {
                display: '小黑',
                value: 147
              },
              {
                display: '小明',
                value: 123
              },
              {
                display: '小黑',
                value: 147
              }
            ]
          }
        },
        fsSensitive: {
          name: 'sensitive',
          label: 'sensitive',
          size: 4,
          help: 'sensitive',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'sensitive',
          model: 'sensitiveValue',
          appScope: $scope,
          prefix: 'name', //前缀

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'sensitive',
          tooltip: 'sensitive',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          // rules: '',
          // format: 'defaultPercentage',
          // filter: '',
          uppercase: false, //Boolean

          options: {
            callback: {
              changed: 'changedFunc'
            },
            positiveOffset: 2,
            negativeOffset: 0,
            mask: true
          }
        },
        fsCustomerSelect: {
          name: 'customer-select',
          label: 'customer-select',
          size: 4,
          help: 'customer-select',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'customer-select',
          model: 'customerSelectValue',
          appScope: $scope,
          template: 'normal', // 'normal' (普通模式下拉框中没有扩展数据) 'company' (级联模式下拉框中有扩展数据)

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'customer-select',
          tooltip: 'customer-select',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          rules: '',
          // format: 'defaultMoney',
          // filter: '',

          options: {
            scrollable: true,
            hasEmptyOption: false,
            filterable: false,
            filter: {
              model: 'value',
              uppercase: true,
              type: 'text',
              options: {
                callback: 'changedFunc'
              }
            },
            callback: {
              changed: 'changedFunc'
            },
            data: [
              {
                display: '小明',
                value: 123,
                subItems: [
                  {
                    display: '小明1-1',
                    value: 1231
                  },
                  {
                    display: '小黑1-2',
                    value: 1471
                  }
                ]
              }
            ]
          }
        },
        fsMultipleSelect: {
          name: 'multiple-select',
          label: 'multiple-select',
          size: 4,
          help: 'multiple-select',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'multiple-select',
          model: 'multipleSelectValue',
          appScope: $scope,

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'multiple-select',
          tooltip: 'multiple-select tooltip',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          options: {
            hasEmptyOption: true,
            data: [
              {
                display: '小明',
                value: 123
              }
            ]
          }
        },
        fsLookupText: {
          name: 'lookup-text',
          label: 'lookup-text',
          size: 4,
          help: 'lookup-text',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'lookup-text',
          model: 'lookupTextValue',
          appScope: $scope,

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'lookup-text',
          tooltip: 'lookup-text tooltip',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          options: {
            id: 'modalDemo',
            size: [500, 300], //弹框尺寸
            manualInput: true, //是否允许直接输入
            boundTo: {
              colorValue: 'lookupTextValue'
            },
            // params: {
            //   searchForCreateFlag: true,
            //   showSelectAllButton: 'N',
            //   createPiOrIvFlag: true
            // },
            callback: {
              //自定义 ok / close 事件
              ok: 'okFunc'
              // close:''
            }
            // okEvent:'',
            // cancelEvent:''
          }
        },
        fsLookupMultiple: {
          name: 'lookup-multiple',
          label: 'lookup-multiple',
          size: 4,
          help: 'lookup-multiple',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'lookup-multiple',
          model: 'lookupMultipleValue',
          appScope: $scope,

          showStyle: 'edit', //'view','readonly','edit' or expression

          placeholder: 'lookup-multiple',
          tooltip: 'lookup-multiple tooltip',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right',

          options: {
            id: 'modalDemo2',
            size: [500, 300], //弹框尺寸
            manualInput: true, //是否允许直接输入
            boundTo: {
              colorValue: 'value'
            }
            // params: {
            //   searchForCreateFlag: true,
            //   showSelectAllButton: 'N',
            //   createPiOrIvFlag: true
            // },
            // callback:{ //自定义 ok / close 事件
            //   ok:'',
            //   close:''
            //   remove: '',
            //   removeAll: ''
            // },
            // okEvent:''
            // cancelEvent:''
          }
        },
        fsFileUpload: {
          name: 'file-upload',
          label: 'file-upload',
          size: 4,
          help: 'file-upload',
          inputClass: '',

          showLabel: true,
          isRequired: true,
          isNecessary: false,

          type: 'file-upload',
          model: 'fileUploadValue',
          appScope: $scope,

          placeholder: 'placeholder placeholder',
          tooltip: 'tooltip tooltip',

          // tooltipTemplateUrl: '',
          tooltipClass: '',
          tooltipPlacement: 'top-right'

          // options: {
          //   url: '',//文件上传的路径
          //   downloadUrl: '',//文件下载的路径
          //   isMultiple: '',//是否使用多文件上传功能
          //   mimeTypes: '',//文件类型
          //   maxFileSize: '',//文件大小的上限
          //   minFileSize: '',//文件大小的下限(最小不能小于1b)
          //   fileCount: '',//最大上传文件数量

          //   data: [
          //     {
          //       display: '小明',
          //       value: 123
          //     },
          //     {
          //       display: '小黑',
          //       value: 147
          //     }
          //   ]
          // }
        },
        fsButtons: {
          name: 'buttons',
          label: 'buttons',
          model: 'buttonsValue',
          type: 'buttons',

          // groupClass: '',
          appScope: $scope,
          buttons: [
            {
              name: 'button',
              label: 'button',
              type: 'button',
              btnScope: $scope,
              options: {
                icon: 'setup',
                showIcon: false,
                callback: {
                  click: 'callbackFunc'
                },
                hotKey: 'alt+1'
              }
            }
          ]
        },
        fsButton: {
          name: 'button',
          label: 'button',
          size: 4,

          showLabel: true,

          type: 'button', //'button','submit','search','reset' 默认submit
          // authorization:'', // 默认有设置
          // permission:'', //'默认'*'
          // btnClass: 'btn-default' 默认 btn-primary,
          // tooltipPlacement: 'top-right', 默认 top-left,
          appScope: $scope,

          text: 'button',

          tooltip: 'button tooltip',
          // tooltipTemplateUrl: '',
          // tooltipClass: '',

          options: {
            icon: 'setup',
            showIcon: false,
            callback: {
              click: 'callbackFunc'
            },
            hotKey: 'alt+1'
          }
        },
        testComponent: {
          type: 'testComponent', //fs-grid 填充的组件类型名
          model: 'testComponentValue', //和ngModel关联的字段

          name: 'testComponent', //
          label: 'testComponent', //组件标题名

          size: 4, //控制组件在页面中所占单元格的长度
          tooltip: 'testComponent tooltip' //tooltip 中的提示内容
        },
        fsTextarea2: {
          name: 'textarea2',
          label: 'textarea2',
          model: 'textareaValue2',
          type: 'textarea',
          size: 4,
          showLabel: true,
          isRequired: true,
          placeholder: 'textarea2',
          tooltip: 'textarea2',
          uppercase: true, //Boolean
          help: 'textarea2',
          options: {
            rows: '2', //行数
            cols: '4' //列数
          }
        }
      };

      // TODO: 组件回调页面controller中的方法
      $scope.callbackFunc = function() {
        console.log(arguments);
      };

      // TODO: 组件回调页面controller中的方法
      $scope.changedFunc = function() {
        console.log('call back changedFunc');
      };

      // $scope.dat = new Date();
      // $scope.format = 'yyyy/MM/dd';
      // $scope.altInputFormats = ['yyyy/M!/d!'];

      // $scope.popup1 = {
      //   opened: false
      // };
      // $scope.open1 = function() {
      //   $scope.popup1.opened = true;
      // };

      $scope.okFunc = function() {
        console.log(arguments);
      };
    }
  ])
  .controller('ModalDemoCtrl', function($scope, $uibModal, $log) {
    $scope.items = ['item1', 'item2', 'item3'];

    $scope.open = function(size) {
      var modalInstance = $uibModal.open({
        // templateUrl: 'myModalContent.html',
        template: '<div><h1>ModalDemoCtrl</h1></div>',
        controller: 'ModalInstanceCtrl',
        backdrop: 'static',
        size: size,
        resolve: {
          items1: function() {
            return $scope.items;
          }
        }
      });

      modalInstance.result.then(
        function(selectedItem) {
          $scope.selected = selectedItem;
        },
        function() {
          $log.info('Modal dismissed at: ' + new Date());
        }
      );
    };

    $scope.toggleAnimation = function() {
      $scope.animationsEnabled = !$scope.animationsEnabled;
    };
  })
  .controller('ModalInstanceCtrl', function($scope, $uibModalInstance, items1) {
    $scope.items = items1;
    $scope.selected = {
      item: $scope.items[0]
    };

    $scope.ok = function() {
      $uibModalInstance.close($scope.selected.item);
    };

    $scope.cancel = function() {
      $uibModalInstance.dismiss('cancel');
    };
  });
